import { createStore, applyMiddleware, combineReducers } from 'redux'
import { composeWithDevTools } from '@redux-devtools/extension'
// 引入saga中间件
import createSagaMiddleware from 'redux-saga'
// 引入主saga程序
import mainSaga from './saga'

// 导入reducer
import user from '../reducer/user'
// import common from '@/reducer/common'

// 得到saga中间件
const sagaMiddleware = createSagaMiddleware()

// reducer模块化
const reducer = combineReducers({ user })

const store = createStore(reducer, composeWithDevTools(applyMiddleware(sagaMiddleware)))

// 执行saga监听
sagaMiddleware.run(mainSaga)

export default store
